﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows.Media;

namespace MapEditor
{
    public enum ID
    {
        ROM,
        Mario,
        Land,
        Brick
    }

    public class Object
    {
        public int Number { get; set; }
        public ID Id { get; set; }
        public int PosX { get; set; }
        public int PosY { get; set; }
        public Rectangle Rect { get; set; }

        public System.Drawing.Rectangle Rectangle
        {
            get
            {
                int x = (int)Canvas.GetLeft(Rect);
                int y = (int)Canvas.GetTop(Rect);

                return new System.Drawing.Rectangle(x, y, (int)Rect.Width, (int)Rect.Height);
            }

            set
            {
                Canvas.SetLeft(Rect, value.X);
                Canvas.SetTop(Rect, value.Y);
            }

        }
        public Canvas Image { get; set; }

        public Object(ID id, int x, int y, Canvas cv)
        {
            Number = -1;
            Id = id;
            PosX = x;
            PosY = y;

            Rect = new Rectangle();
            Canvas.SetLeft(Rect, x - cv.Width / 2);
            Canvas.SetTop(Rect, y - cv.Height / 2);
            Rect.Width = cv.Width;
            Rect.Height = cv.Height;
            Rect.Stroke = new SolidColorBrush(Colors.Blue);
            Rect.StrokeThickness = 3;

            Image = cv;

        }

        public Object(ID id, int x, int y, Canvas cv, int width, int height)    // width, height of ROM
        {
            Number = -1;
            Id = id;
            PosX = x;
            PosY = y;
            
            Rect = new Rectangle();
            Canvas.SetLeft(Rect, x);
            Canvas.SetTop(Rect, y);
            Rect.Width = width;
            Rect.Height = height;
            Rect.Stroke = new SolidColorBrush(Colors.Blue);
            Rect.StrokeThickness = 3;

            Image = cv;
        }
    }
}
